/*
 *  Copyright 2001-2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package ar.uba.fi.posgrado.economy.dao.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;

import ar.uba.fi.posgrado.common.dao.AbstractDAO;
import ar.uba.fi.posgrado.common.dao.DAOException;
import ar.uba.fi.posgrado.common.model.ExampleClass;
import ar.uba.fi.posgrado.economy.dao.ExampleClassDAO;

/**
 * Esta clase de por si ya tiene implementado todos los metodos de AbstractDAO.<br>
 * En caso de querer eliminar alguno entonces se los sobreescribe y no se hace nada.<br>
 * 
 * 
 * @author nicolas.gonzalez
 */
public class ExampleClassDAOImpl extends AbstractDAO implements ExampleClassDAO {

    /** Logger */
    private static Logger logger = Logger.getLogger(ExampleClassDAOImpl.class);
    
    /**
     * @see ar.uba.fi.posgrado.common.dao.AbstractDAO#getClazz()
     */
    @SuppressWarnings("unchecked")
    @Override
    protected Class getClazz() {
        return ExampleClass.class;
    }

    /**
     * @see ar.uba.fi.posgrado.economy.dao.ExampleClassDAO#findByCriteria(ar.uba.fi.posgrado.common.model.ExampleClass)
     */
    public List<ExampleClass> findByCriteria(ExampleClass example) {
        // Se hace lo q se tenga q hacer!!
        
        return null;
    }

    /**
     * @see ar.uba.fi.posgrado.common.dao.GenericDAO#findAll()
     */
    @SuppressWarnings("unchecked")
    public List<ExampleClass> findAll() throws DAOException {
        List response = null;
        Class clazz = this.getClazz();
        if (logger.isDebugEnabled()) {
            logger.debug("Buscando todas las instancias de " + clazz);
        }
        try {
            response = this.getHibernateTemplate().loadAll(clazz);
            }
        catch (DataAccessException e) {
            throw new DAOException("Excepcion al buscar las intancias de " 
                                    + clazz + ". Mensaje: " + e.getMessage(),e);
        }
        
        return response;
    }


}
